//
//  UIUtils.h
//  WXTime
//
//  Created by wei.chen on 12-7-22.
//  Copyright (c) 2012年 www.iphonetrain.com 无限互联ios开发培训中心 All rights reserved.
//

#define REGEX_USER_NAME_LIMIT @"^.{3,10}$"          // 匹配类容是否在3~10位间
#define REGEX_USER_NAME @"[A-Za-z0-9]{3,10}"        // 匹配类容是否在3~10位间，并且是大小写字母、数字、
#define REGEX_USER_PASSWORD @"[A-Za-z0-9]{6,16}"        // 匹配类容是否在6~12位间，并且是大小写字母、数字、
#define REGEX_PHONE_DEFAULT @"^1[34578]\\d{9}$"                       // 匹配类容是否是电话号码
#define REGEX_EMAIL @"[A-Z0-9a-z._%+-]{3,}+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"         // 匹配类容是否是邮箱
#define REGEX_USER_NAME_CHESKER @"[a-zA-Z\u4e00-\u9fa5][a-zA-Z0-9\u4e00-\u9fa5]+"   // 匹配类容是否是汉字，数字，字母
#define REGEX_IDENTITY_CARD @"^(\\d{14}|\\d{17})(\\d|[xX])$" // 身份证
#define REGEX_BANK_CARD @"^([0-9]{16}|[0-9]{19})$" // 银行卡
#define REGEX_NUMBER @"^[0-9]*$" // 纯数字

#import <Foundation/Foundation.h>
#import "AppDelegate.h"

@interface Utils : NSObject
//读取本地图片路径
+(NSString *)imgPath: (NSString *)path;
//16进制颜色设置
+ (UIColor *) colorWithHexString: (NSString *)color;
//获取documents下的文件路径
+ (NSString *)getDocumentsPath:(NSString *)fileName;

// date 格式化为 string
+ (NSString *) stringFromFomate:(NSDate*)date formate:(NSString*)formate;

// string 格式化为 date
+ (NSDate *) dateFromFomate:(NSString *)datestring formate:(NSString*)formate;

//Sat Jan 12 11:50:16 +0800 2013
+ (NSString *)fomateString:(NSString *)datestring;

//返回本机版本
+(float)OSVersion;

//获取字符串高度
+ (float)heightForString:(NSString *)value fontSize:(float)fontSize andWidth:(float)width;

//指定字符串变色
+(void)fuwenbenLabel:(UILabel *)labell FontNumber:(id)font AndRange:(NSRange)range AndColor:(UIColor *)vaColor;

//获取字符串宽度
+ (float)widthForString:(NSString *)value fontSize:(float)fontSize andHeight:(float)height;

//MD5加密
+ (NSString *)md5:(NSString *)str;

//返回当前时间的时间戳
+ (NSString *)getCurrentDateStamp;

//返回指定时间13位时间戳
+ (NSString *)dateStampWithDate:(NSDate *)date;

//图片截取
+ (UIImage*) crop:(UIImage*)theImage;

//返回好多分钟前
+(NSString *) compareCurrentTime:(NSDate*) compareDate;

// 正则表达式
+ (BOOL)checkContent:(NSString *)content regex:(NSString *)regex;
// 获取网络时间
+ (NSDate *)getInternetDate;
// base64
+ (NSString*)encodeBase64String:(NSString*)input;
+ (NSString*)decodeBase64String:(NSString*)input;
+ (NSString*)encodeBase64Data:(NSData*)data;
+ (NSString*)decodeBase64Data:(NSData*)data;

// 拼接GET请求路径
+ (NSString *)generateURL:(NSString*)baseURL params:(NSDictionary*)params;

// 唯一标识
+ (NSString*)UUID;

// 获取设备型号
+ (NSString *)deviceModel;

// 获取pp版本
+ (NSString *)appVersion;

// 时间戳转时间
+ (NSDate *)dateFromTimestamp:(NSNumber *)timestamp;

// 时间戳转成固定格式时间字符串
+ (NSString *)dateStringWithTimestamp:(NSNumber *)Timestamp;

// 拨打电话
+ (void)callPhone:(NSString *)phone viewController:(UIViewController *)vc;
/**
 *  根据图片url获取图片尺寸
 */
+ (CGSize)getImageSizeWithURL:(id)URL;

+ (CGFloat)iphone6AutoScaleW:(CGFloat)w;
    

+ (CGFloat)iphone6AutoScaleH:(CGFloat)h;
  


+ (CGFloat)iphone5AutoScaleW:(CGFloat)w;
//经纬度计算
+(double)distanceBetweenOrderBy:(double) lat1 :(double) lat2 :(double) lng1 :(double) lng2;

// 比较时间
+ (int)compareOneDay:(NSDate *)oneDay withAnotherDay:(NSDate *)anotherDay;

// 时间戳转nsdate
+(NSDate *)Get_timeForDate:(NSString *)dateStr;

// 时间戳转换
+(NSString *)get_time:(NSString *)dateStr;
// 适配ios7横屏
+ (CGFloat)cellContentViewWith;

@end
